@ibiz-template-plugin/ibiz-file-previewer 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1241,6 +1241,409 @@ const copyTextToClipboard = async (text) => {
1241
1241
  return fallbackCopyTextToClipboard(text);
1242
1242
  }
1243
1243
  };
1244
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1245
+ function getDefaultExportFromCjs(x2) {
1246
+ return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
1247
+ }
1248
+ function assertPath(path) {
1249
+ if (typeof path !== "string") {
1250
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
1251
+ }
1252
+ }
1253
+ function normalizeStringPosix(path, allowAboveRoot) {
1254
+ var res = "";
1255
+ var lastSegmentLength = 0;
1256
+ var lastSlash = -1;
1257
+ var dots = 0;
1258
+ var code;
1259
+ for (var i2 = 0; i2 <= path.length; ++i2) {
1260
+ if (i2 < path.length)
1261
+ code = path.charCodeAt(i2);
1262
+ else if (code === 47)
1263
+ break;
1264
+ else
1265
+ code = 47;
1266
+ if (code === 47) {
1267
+ if (lastSlash === i2 - 1 || dots === 1) ;
1268
+ else if (lastSlash !== i2 - 1 && dots === 2) {
1269
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
1270
+ if (res.length > 2) {
1271
+ var lastSlashIndex = res.lastIndexOf("/");
1272
+ if (lastSlashIndex !== res.length - 1) {
1273
+ if (lastSlashIndex === -1) {
1274
+ res = "";
1275
+ lastSegmentLength = 0;
1276
+ } else {
1277
+ res = res.slice(0, lastSlashIndex);
1278
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1279
+ }
1280
+ lastSlash = i2;
1281
+ dots = 0;
1282
+ continue;
1283
+ }
1284
+ } else if (res.length === 2 || res.length === 1) {
1285
+ res = "";
1286
+ lastSegmentLength = 0;
1287
+ lastSlash = i2;
1288
+ dots = 0;
1289
+ continue;
1290
+ }
1291
+ }
1292
+ if (allowAboveRoot) {
1293
+ if (res.length > 0)
1294
+ res += "/..";
1295
+ else
1296
+ res = "..";
1297
+ lastSegmentLength = 2;
1298
+ }
1299
+ } else {
1300
+ if (res.length > 0)
1301
+ res += "/" + path.slice(lastSlash + 1, i2);
1302
+ else
1303
+ res = path.slice(lastSlash + 1, i2);
1304
+ lastSegmentLength = i2 - lastSlash - 1;
1305
+ }
1306
+ lastSlash = i2;
1307
+ dots = 0;
1308
+ } else if (code === 46 && dots !== -1) {
1309
+ ++dots;
1310
+ } else {
1311
+ dots = -1;
1312
+ }
1313
+ }
1314
+ return res;
1315
+ }
1316
+ function _format(sep, pathObject) {
1317
+ var dir = pathObject.dir || pathObject.root;
1318
+ var base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
1319
+ if (!dir) {
1320
+ return base;
1321
+ }
1322
+ if (dir === pathObject.root) {
1323
+ return dir + base;
1324
+ }
1325
+ return dir + sep + base;
1326
+ }
1327
+ var posix = {
1328
+ // path.resolve([from ...], to)
1329
+ resolve: function resolve() {
1330
+ var resolvedPath = "";
1331
+ var resolvedAbsolute = false;
1332
+ var cwd;
1333
+ for (var i2 = arguments.length - 1; i2 >= -1 && !resolvedAbsolute; i2--) {
1334
+ var path;
1335
+ if (i2 >= 0)
1336
+ path = arguments[i2];
1337
+ else {
1338
+ if (cwd === void 0)
1339
+ cwd = process.cwd();
1340
+ path = cwd;
1341
+ }
1342
+ assertPath(path);
1343
+ if (path.length === 0) {
1344
+ continue;
1345
+ }
1346
+ resolvedPath = path + "/" + resolvedPath;
1347
+ resolvedAbsolute = path.charCodeAt(0) === 47;
1348
+ }
1349
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
1350
+ if (resolvedAbsolute) {
1351
+ if (resolvedPath.length > 0)
1352
+ return "/" + resolvedPath;
1353
+ else
1354
+ return "/";
1355
+ } else if (resolvedPath.length > 0) {
1356
+ return resolvedPath;
1357
+ } else {
1358
+ return ".";
1359
+ }
1360
+ },
1361
+ normalize: function normalize(path) {
1362
+ assertPath(path);
1363
+ if (path.length === 0) return ".";
1364
+ var isAbsolute2 = path.charCodeAt(0) === 47;
1365
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47;
1366
+ path = normalizeStringPosix(path, !isAbsolute2);
1367
+ if (path.length === 0 && !isAbsolute2) path = ".";
1368
+ if (path.length > 0 && trailingSeparator) path += "/";
1369
+ if (isAbsolute2) return "/" + path;
1370
+ return path;
1371
+ },
1372
+ isAbsolute: function isAbsolute(path) {
1373
+ assertPath(path);
1374
+ return path.length > 0 && path.charCodeAt(0) === 47;
1375
+ },
1376
+ join: function join() {
1377
+ if (arguments.length === 0)
1378
+ return ".";
1379
+ var joined;
1380
+ for (var i2 = 0; i2 < arguments.length; ++i2) {
1381
+ var arg = arguments[i2];
1382
+ assertPath(arg);
1383
+ if (arg.length > 0) {
1384
+ if (joined === void 0)
1385
+ joined = arg;
1386
+ else
1387
+ joined += "/" + arg;
1388
+ }
1389
+ }
1390
+ if (joined === void 0)
1391
+ return ".";
1392
+ return posix.normalize(joined);
1393
+ },
1394
+ relative: function relative(from, to) {
1395
+ assertPath(from);
1396
+ assertPath(to);
1397
+ if (from === to) return "";
1398
+ from = posix.resolve(from);
1399
+ to = posix.resolve(to);
1400
+ if (from === to) return "";
1401
+ var fromStart = 1;
1402
+ for (; fromStart < from.length; ++fromStart) {
1403
+ if (from.charCodeAt(fromStart) !== 47)
1404
+ break;
1405
+ }
1406
+ var fromEnd = from.length;
1407
+ var fromLen = fromEnd - fromStart;
1408
+ var toStart = 1;
1409
+ for (; toStart < to.length; ++toStart) {
1410
+ if (to.charCodeAt(toStart) !== 47)
1411
+ break;
1412
+ }
1413
+ var toEnd = to.length;
1414
+ var toLen = toEnd - toStart;
1415
+ var length = fromLen < toLen ? fromLen : toLen;
1416
+ var lastCommonSep = -1;
1417
+ var i2 = 0;
1418
+ for (; i2 <= length; ++i2) {
1419
+ if (i2 === length) {
1420
+ if (toLen > length) {
1421
+ if (to.charCodeAt(toStart + i2) === 47) {
1422
+ return to.slice(toStart + i2 + 1);
1423
+ } else if (i2 === 0) {
1424
+ return to.slice(toStart + i2);
1425
+ }
1426
+ } else if (fromLen > length) {
1427
+ if (from.charCodeAt(fromStart + i2) === 47) {
1428
+ lastCommonSep = i2;
1429
+ } else if (i2 === 0) {
1430
+ lastCommonSep = 0;
1431
+ }
1432
+ }
1433
+ break;
1434
+ }
1435
+ var fromCode = from.charCodeAt(fromStart + i2);
1436
+ var toCode = to.charCodeAt(toStart + i2);
1437
+ if (fromCode !== toCode)
1438
+ break;
1439
+ else if (fromCode === 47)
1440
+ lastCommonSep = i2;
1441
+ }
1442
+ var out = "";
1443
+ for (i2 = fromStart + lastCommonSep + 1; i2 <= fromEnd; ++i2) {
1444
+ if (i2 === fromEnd || from.charCodeAt(i2) === 47) {
1445
+ if (out.length === 0)
1446
+ out += "..";
1447
+ else
1448
+ out += "/..";
1449
+ }
1450
+ }
1451
+ if (out.length > 0)
1452
+ return out + to.slice(toStart + lastCommonSep);
1453
+ else {
1454
+ toStart += lastCommonSep;
1455
+ if (to.charCodeAt(toStart) === 47)
1456
+ ++toStart;
1457
+ return to.slice(toStart);
1458
+ }
1459
+ },
1460
+ _makeLong: function _makeLong(path) {
1461
+ return path;
1462
+ },
1463
+ dirname: function dirname(path) {
1464
+ assertPath(path);
1465
+ if (path.length === 0) return ".";
1466
+ var code = path.charCodeAt(0);
1467
+ var hasRoot = code === 47;
1468
+ var end = -1;
1469
+ var matchedSlash = true;
1470
+ for (var i2 = path.length - 1; i2 >= 1; --i2) {
1471
+ code = path.charCodeAt(i2);
1472
+ if (code === 47) {
1473
+ if (!matchedSlash) {
1474
+ end = i2;
1475
+ break;
1476
+ }
1477
+ } else {
1478
+ matchedSlash = false;
1479
+ }
1480
+ }
1481
+ if (end === -1) return hasRoot ? "/" : ".";
1482
+ if (hasRoot && end === 1) return "//";
1483
+ return path.slice(0, end);
1484
+ },
1485
+ basename: function basename(path, ext) {
1486
+ if (ext !== void 0 && typeof ext !== "string") throw new TypeError('"ext" argument must be a string');
1487
+ assertPath(path);
1488
+ var start = 0;
1489
+ var end = -1;
1490
+ var matchedSlash = true;
1491
+ var i2;
1492
+ if (ext !== void 0 && ext.length > 0 && ext.length <= path.length) {
1493
+ if (ext.length === path.length && ext === path) return "";
1494
+ var extIdx = ext.length - 1;
1495
+ var firstNonSlashEnd = -1;
1496
+ for (i2 = path.length - 1; i2 >= 0; --i2) {
1497
+ var code = path.charCodeAt(i2);
1498
+ if (code === 47) {
1499
+ if (!matchedSlash) {
1500
+ start = i2 + 1;
1501
+ break;
1502
+ }
1503
+ } else {
1504
+ if (firstNonSlashEnd === -1) {
1505
+ matchedSlash = false;
1506
+ firstNonSlashEnd = i2 + 1;
1507
+ }
1508
+ if (extIdx >= 0) {
1509
+ if (code === ext.charCodeAt(extIdx)) {
1510
+ if (--extIdx === -1) {
1511
+ end = i2;
1512
+ }
1513
+ } else {
1514
+ extIdx = -1;
1515
+ end = firstNonSlashEnd;
1516
+ }
1517
+ }
1518
+ }
1519
+ }
1520
+ if (start === end) end = firstNonSlashEnd;
1521
+ else if (end === -1) end = path.length;
1522
+ return path.slice(start, end);
1523
+ } else {
1524
+ for (i2 = path.length - 1; i2 >= 0; --i2) {
1525
+ if (path.charCodeAt(i2) === 47) {
1526
+ if (!matchedSlash) {
1527
+ start = i2 + 1;
1528
+ break;
1529
+ }
1530
+ } else if (end === -1) {
1531
+ matchedSlash = false;
1532
+ end = i2 + 1;
1533
+ }
1534
+ }
1535
+ if (end === -1) return "";
1536
+ return path.slice(start, end);
1537
+ }
1538
+ },
1539
+ extname: function extname(path) {
1540
+ assertPath(path);
1541
+ var startDot = -1;
1542
+ var startPart = 0;
1543
+ var end = -1;
1544
+ var matchedSlash = true;
1545
+ var preDotState = 0;
1546
+ for (var i2 = path.length - 1; i2 >= 0; --i2) {
1547
+ var code = path.charCodeAt(i2);
1548
+ if (code === 47) {
1549
+ if (!matchedSlash) {
1550
+ startPart = i2 + 1;
1551
+ break;
1552
+ }
1553
+ continue;
1554
+ }
1555
+ if (end === -1) {
1556
+ matchedSlash = false;
1557
+ end = i2 + 1;
1558
+ }
1559
+ if (code === 46) {
1560
+ if (startDot === -1)
1561
+ startDot = i2;
1562
+ else if (preDotState !== 1)
1563
+ preDotState = 1;
1564
+ } else if (startDot !== -1) {
1565
+ preDotState = -1;
1566
+ }
1567
+ }
1568
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
1569
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
1570
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
1571
+ return "";
1572
+ }
1573
+ return path.slice(startDot, end);
1574
+ },
1575
+ format: function format(pathObject) {
1576
+ if (pathObject === null || typeof pathObject !== "object") {
1577
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
1578
+ }
1579
+ return _format("/", pathObject);
1580
+ },
1581
+ parse: function parse(path) {
1582
+ assertPath(path);
1583
+ var ret = { root: "", dir: "", base: "", ext: "", name: "" };
1584
+ if (path.length === 0) return ret;
1585
+ var code = path.charCodeAt(0);
1586
+ var isAbsolute2 = code === 47;
1587
+ var start;
1588
+ if (isAbsolute2) {
1589
+ ret.root = "/";
1590
+ start = 1;
1591
+ } else {
1592
+ start = 0;
1593
+ }
1594
+ var startDot = -1;
1595
+ var startPart = 0;
1596
+ var end = -1;
1597
+ var matchedSlash = true;
1598
+ var i2 = path.length - 1;
1599
+ var preDotState = 0;
1600
+ for (; i2 >= start; --i2) {
1601
+ code = path.charCodeAt(i2);
1602
+ if (code === 47) {
1603
+ if (!matchedSlash) {
1604
+ startPart = i2 + 1;
1605
+ break;
1606
+ }
1607
+ continue;
1608
+ }
1609
+ if (end === -1) {
1610
+ matchedSlash = false;
1611
+ end = i2 + 1;
1612
+ }
1613
+ if (code === 46) {
1614
+ if (startDot === -1) startDot = i2;
1615
+ else if (preDotState !== 1) preDotState = 1;
1616
+ } else if (startDot !== -1) {
1617
+ preDotState = -1;
1618
+ }
1619
+ }
1620
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
1621
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
1622
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
1623
+ if (end !== -1) {
1624
+ if (startPart === 0 && isAbsolute2) ret.base = ret.name = path.slice(1, end);
1625
+ else ret.base = ret.name = path.slice(startPart, end);
1626
+ }
1627
+ } else {
1628
+ if (startPart === 0 && isAbsolute2) {
1629
+ ret.name = path.slice(1, startDot);
1630
+ ret.base = path.slice(1, end);
1631
+ } else {
1632
+ ret.name = path.slice(startPart, startDot);
1633
+ ret.base = path.slice(startPart, end);
1634
+ }
1635
+ ret.ext = path.slice(startDot, end);
1636
+ }
1637
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);
1638
+ else if (isAbsolute2) ret.dir = "/";
1639
+ return ret;
1640
+ },
1641
+ sep: "/",
1642
+ delimiter: ":",
1643
+ win32: null,
1644
+ posix: null
1645
+ };
1646
+ posix.posix = posix;
1244
1647
  var f = 0;
1245
1648
  function u(e2, t2, n2, o2, i2, u2) {
1246
1649
  t2 || (t2 = {});
@@ -1255,10 +1658,21 @@ const FilePreviewHtml = (props) => {
1255
1658
  y$1(() => {
1256
1659
  if (containerRef.current) {
1257
1660
  const shadowRoot = containerRef.current.attachShadow({ mode: "open" });
1258
- const content = '\n <style>\n .content-container {\n height: 100%;\n width: 100%;\n }\n </style>\n <div class="content-container">\n '.concat(props.controller.state.value.content, "\n </div>\n ");
1259
- shadowRoot.innerHTML = content;
1661
+ const computedStyle = getComputedStyle(containerRef.current);
1662
+ const trackBgColor = computedStyle.getPropertyValue("--track-bg-color").trim();
1663
+ const thumbBgColor = computedStyle.getPropertyValue("--thumb-bg-color").trim();
1664
+ const thumbHoverBgColor = computedStyle.getPropertyValue("--thumb-hover-bg-color").trim();
1665
+ const scrollbarStyle = "\n <style>\n ::-webkit-scrollbar {\n display: block;\n width: 6px;\n height: 6px;\n }\n ::-webkit-scrollbar-track {\n background: ".concat(trackBgColor, ";\n }\n ::-webkit-scrollbar-thumb {\n background: ").concat(thumbBgColor, ";\n border-radius: 2px;\n }\n ::-webkit-scrollbar-thumb:hover {\n background: ").concat(thumbHoverBgColor, ";\n }\n </style>\n ");
1666
+ const rawContent = props.controller.state.value.content;
1667
+ const injectedContent = rawContent.includes("<head>") ? rawContent.replace("<head>", "<head>".concat(scrollbarStyle)) : "".concat(scrollbarStyle).concat(rawContent);
1668
+ const blob = new Blob([injectedContent], { type: "text/html" });
1669
+ const url = URL.createObjectURL(blob);
1670
+ shadowRoot.innerHTML = '\n <style>\n iframe {\n width: 100%;\n height: 100%;\n border: none;\n display: block;\n }\n </style>\n <iframe src="'.concat(url, '"></iframe>\n ');
1671
+ URL.revokeObjectURL(url);
1672
+ props.onInitialization();
1673
+ } else {
1674
+ props.onInitialization();
1260
1675
  }
1261
- props.onInitialization();
1262
1676
  }, []);
1263
1677
  return /* @__PURE__ */ u("div", { className: "file-preview-html ".concat(props.controller.state.value.theme), children: /* @__PURE__ */ u("div", { ref: containerRef, className: "container" }) });
1264
1678
  };
@@ -1918,10 +2332,6 @@ const FilePreviewImage = (props) => {
1918
2332
  ] }) })
1919
2333
  ] });
1920
2334
  };
1921
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1922
- function getDefaultExportFromCjs(x2) {
1923
- return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
1924
- }
1925
2335
  var dist = { exports: {} };
1926
2336
  /*!
1927
2337
  * Vditor v3.11.2 - A markdown editor written in TypeScript.
@@ -3524,11 +3934,11 @@ var dist = { exports: {} };
3524
3934
  };
3525
3935
  var __awaiter = function(thisArg, _arguments, P2, generator) {
3526
3936
  function adopt(value) {
3527
- return value instanceof P2 ? value : new P2(function(resolve) {
3528
- resolve(value);
3937
+ return value instanceof P2 ? value : new P2(function(resolve2) {
3938
+ resolve2(value);
3529
3939
  });
3530
3940
  }
3531
- return new (P2 || (P2 = Promise))(function(resolve, reject) {
3941
+ return new (P2 || (P2 = Promise))(function(resolve2, reject) {
3532
3942
  function fulfilled(value) {
3533
3943
  try {
3534
3944
  step(generator.next(value));
@@ -3544,7 +3954,7 @@ var dist = { exports: {} };
3544
3954
  }
3545
3955
  }
3546
3956
  function step(result) {
3547
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
3957
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
3548
3958
  }
3549
3959
  step((generator = generator.apply(thisArg, _arguments || [])).next());
3550
3960
  });
@@ -4418,11 +4828,11 @@ var dist = { exports: {} };
4418
4828
  var _util_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__2(494);
4419
4829
  var __awaiter = function(thisArg, _arguments, P2, generator) {
4420
4830
  function adopt(value) {
4421
- return value instanceof P2 ? value : new P2(function(resolve) {
4422
- resolve(value);
4831
+ return value instanceof P2 ? value : new P2(function(resolve2) {
4832
+ resolve2(value);
4423
4833
  });
4424
4834
  }
4425
- return new (P2 || (P2 = Promise))(function(resolve, reject) {
4835
+ return new (P2 || (P2 = Promise))(function(resolve2, reject) {
4426
4836
  function fulfilled(value) {
4427
4837
  try {
4428
4838
  step(generator.next(value));
@@ -4438,7 +4848,7 @@ var dist = { exports: {} };
4438
4848
  }
4439
4849
  }
4440
4850
  function step(result) {
4441
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
4851
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
4442
4852
  }
4443
4853
  step((generator = generator.apply(thisArg, _arguments || [])).next());
4444
4854
  });
@@ -5155,11 +5565,11 @@ var dist = { exports: {} };
5155
5565
  var _util_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__2(494);
5156
5566
  var __awaiter = function(thisArg, _arguments, P2, generator) {
5157
5567
  function adopt(value) {
5158
- return value instanceof P2 ? value : new P2(function(resolve) {
5159
- resolve(value);
5568
+ return value instanceof P2 ? value : new P2(function(resolve2) {
5569
+ resolve2(value);
5160
5570
  });
5161
5571
  }
5162
- return new (P2 || (P2 = Promise))(function(resolve, reject) {
5572
+ return new (P2 || (P2 = Promise))(function(resolve2, reject) {
5163
5573
  function fulfilled(value) {
5164
5574
  try {
5165
5575
  step(generator.next(value));
@@ -5175,7 +5585,7 @@ var dist = { exports: {} };
5175
5585
  }
5176
5586
  }
5177
5587
  function step(result) {
5178
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
5588
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
5179
5589
  }
5180
5590
  step((generator = generator.apply(thisArg, _arguments || [])).next());
5181
5591
  });
@@ -5761,9 +6171,9 @@ var dist = { exports: {} };
5761
6171
  document.head.appendChild(scriptElement);
5762
6172
  };
5763
6173
  var addScript = function(path, id) {
5764
- return new Promise(function(resolve, reject) {
6174
+ return new Promise(function(resolve2, reject) {
5765
6175
  if (document.getElementById(id)) {
5766
- resolve(true);
6176
+ resolve2(true);
5767
6177
  return false;
5768
6178
  }
5769
6179
  var scriptElement = document.createElement("script");
@@ -5776,11 +6186,11 @@ var dist = { exports: {} };
5776
6186
  scriptElement.onload = function() {
5777
6187
  if (document.getElementById(id)) {
5778
6188
  scriptElement.remove();
5779
- resolve(true);
6189
+ resolve2(true);
5780
6190
  return false;
5781
6191
  }
5782
6192
  scriptElement.id = id;
5783
- resolve(true);
6193
+ resolve2(true);
5784
6194
  };
5785
6195
  });
5786
6196
  };
@@ -10256,11 +10666,11 @@ var dist = { exports: {} };
10256
10666
  };
10257
10667
  var __awaiter = function(thisArg, _arguments, P2, generator) {
10258
10668
  function adopt(value) {
10259
- return value instanceof P2 ? value : new P2(function(resolve) {
10260
- resolve(value);
10669
+ return value instanceof P2 ? value : new P2(function(resolve2) {
10670
+ resolve2(value);
10261
10671
  });
10262
10672
  }
10263
- return new (P2 || (P2 = Promise))(function(resolve, reject) {
10673
+ return new (P2 || (P2 = Promise))(function(resolve2, reject) {
10264
10674
  function fulfilled(value) {
10265
10675
  try {
10266
10676
  step(generator.next(value));
@@ -10276,7 +10686,7 @@ var dist = { exports: {} };
10276
10686
  }
10277
10687
  }
10278
10688
  function step(result) {
10279
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
10689
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
10280
10690
  }
10281
10691
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10282
10692
  });
@@ -10769,11 +11179,11 @@ var dist = { exports: {} };
10769
11179
  };
10770
11180
  var fixBrowserBehavior_awaiter = function(thisArg, _arguments, P2, generator) {
10771
11181
  function adopt(value) {
10772
- return value instanceof P2 ? value : new P2(function(resolve) {
10773
- resolve(value);
11182
+ return value instanceof P2 ? value : new P2(function(resolve2) {
11183
+ resolve2(value);
10774
11184
  });
10775
11185
  }
10776
- return new (P2 || (P2 = Promise))(function(resolve, reject) {
11186
+ return new (P2 || (P2 = Promise))(function(resolve2, reject) {
10777
11187
  function fulfilled(value) {
10778
11188
  try {
10779
11189
  step(generator.next(value));
@@ -10789,7 +11199,7 @@ var dist = { exports: {} };
10789
11199
  }
10790
11200
  }
10791
11201
  function step(result) {
10792
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
11202
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
10793
11203
  }
10794
11204
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10795
11205
  });
@@ -12408,11 +12818,11 @@ var dist = { exports: {} };
12408
12818
  };
12409
12819
  var hint_awaiter = function(thisArg, _arguments, P2, generator) {
12410
12820
  function adopt(value) {
12411
- return value instanceof P2 ? value : new P2(function(resolve) {
12412
- resolve(value);
12821
+ return value instanceof P2 ? value : new P2(function(resolve2) {
12822
+ resolve2(value);
12413
12823
  });
12414
12824
  }
12415
- return new (P2 || (P2 = Promise))(function(resolve, reject) {
12825
+ return new (P2 || (P2 = Promise))(function(resolve2, reject) {
12416
12826
  function fulfilled(value) {
12417
12827
  try {
12418
12828
  step(generator.next(value));
@@ -12428,7 +12838,7 @@ var dist = { exports: {} };
12428
12838
  }
12429
12839
  }
12430
12840
  function step(result) {
12431
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
12841
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
12432
12842
  }
12433
12843
  step((generator = generator.apply(thisArg, _arguments || [])).next());
12434
12844
  });
@@ -16459,6 +16869,11 @@ const FilePreviewMD = (props) => {
16459
16869
  const c2 = props.controller;
16460
16870
  const vditorEditor = A();
16461
16871
  const previewRef = A(null);
16872
+ const MAX_INIT_LENGTH = 2e3;
16873
+ const CHUNK_SIZE = 2e3;
16874
+ const content = c2.state.value.content;
16875
+ const isLongContent = content.length > MAX_INIT_LENGTH;
16876
+ const initValue = isLongContent ? content.substring(0, MAX_INIT_LENGTH) : content;
16462
16877
  const onOutline = () => {
16463
16878
  if (!vditorEditor.current) return;
16464
16879
  const vditor = vditorEditor.current.vditor;
@@ -16502,10 +16917,39 @@ const FilePreviewMD = (props) => {
16502
16917
  toolbarConfig: {
16503
16918
  hide: true
16504
16919
  },
16505
- value: c2.state.value.content,
16920
+ value: initValue,
16506
16921
  after: () => {
16507
16922
  onPreview();
16508
16923
  props.onInitialization();
16924
+ if (isLongContent) {
16925
+ const remaining = content.substring(MAX_INIT_LENGTH);
16926
+ const chunks = [];
16927
+ for (let i2 = 0; i2 < remaining.length; i2 += CHUNK_SIZE) {
16928
+ chunks.push(remaining.substring(i2, i2 + CHUNK_SIZE));
16929
+ }
16930
+ let index = 0;
16931
+ let accContent = initValue;
16932
+ const insertNextChunk = () => {
16933
+ var _a, _b;
16934
+ if (index < chunks.length) {
16935
+ accContent += chunks[index];
16936
+ const html = vditorEditor.current.vditor.lute.Md2HTML(accContent);
16937
+ vditorEditor.current.renderPreview(html);
16938
+ index++;
16939
+ requestIdleCallback(() => {
16940
+ insertNextChunk();
16941
+ });
16942
+ } else {
16943
+ (_a = vditorEditor.current) == null ? void 0 : _a.setValue(content);
16944
+ (_b = vditorEditor.current) == null ? void 0 : _b.vditor.outline.render(
16945
+ vditorEditor.current.vditor
16946
+ );
16947
+ }
16948
+ };
16949
+ requestIdleCallback(() => {
16950
+ insertNextChunk();
16951
+ });
16952
+ }
16509
16953
  }
16510
16954
  });
16511
16955
  }, []);
@@ -19954,7 +20398,7 @@ TurndownService.prototype = {
19954
20398
  );
19955
20399
  }
19956
20400
  if (input === "") return "";
19957
- var output = process.call(this, new RootNode(input, this.options));
20401
+ var output = process$1.call(this, new RootNode(input, this.options));
19958
20402
  return postProcess.call(this, output);
19959
20403
  },
19960
20404
  /**
@@ -20021,7 +20465,7 @@ TurndownService.prototype = {
20021
20465
  }, string);
20022
20466
  }
20023
20467
  };
20024
- function process(parentNode) {
20468
+ function process$1(parentNode) {
20025
20469
  var self2 = this;
20026
20470
  return reduce.call(parentNode.childNodes, function(output, node) {
20027
20471
  node = new Node(node, self2.options);
@@ -20031,26 +20475,26 @@ function process(parentNode) {
20031
20475
  } else if (node.nodeType === 1) {
20032
20476
  replacement = replacementForNode.call(self2, node);
20033
20477
  }
20034
- return join(output, replacement);
20478
+ return join2(output, replacement);
20035
20479
  }, "");
20036
20480
  }
20037
20481
  function postProcess(output) {
20038
20482
  var self2 = this;
20039
20483
  this.rules.forEach(function(rule) {
20040
20484
  if (typeof rule.append === "function") {
20041
- output = join(output, rule.append(self2.options));
20485
+ output = join2(output, rule.append(self2.options));
20042
20486
  }
20043
20487
  });
20044
20488
  return output.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
20045
20489
  }
20046
20490
  function replacementForNode(node) {
20047
20491
  var rule = this.rules.forNode(node);
20048
- var content = process.call(this, node);
20492
+ var content = process$1.call(this, node);
20049
20493
  var whitespace = node.flankingWhitespace;
20050
20494
  if (whitespace.leading || whitespace.trailing) content = content.trim();
20051
20495
  return whitespace.leading + rule.replacement(content, node, this.options) + whitespace.trailing;
20052
20496
  }
20053
- function join(output, replacement) {
20497
+ function join2(output, replacement) {
20054
20498
  var s1 = trimTrailingNewlines(output);
20055
20499
  var s2 = trimLeadingNewlines(replacement);
20056
20500
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);